home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / nktools.zip / EPSON.PAS < prev    next >
Pascal/Delphi Source File  |  1990-07-02  |  24KB  |  656 lines

  1. unit Epson;
  2. (*====================================================================,,
  3. || MODULE NAME:  Epson                                                ||
  4. || DEPENDENCIES: System                                               ||
  5. || LAST MOD ON:  9007.02                                              ||
  6. || PROGRAMMER:   Naoto Kimura                                         ||
  7. ||                                                                    ||
  8. ||     This unit was developed for doing graphics on the Epson FX-850 ||
  9. || series of printers.  Most of the functions in this unit emulate    ||
  10. || many of the functions of the Graph unit.  Since this is really an  ||
  11. || experimental unit, many of the details are still fluid on how this ||
  12. || unit will operate.                                                 ||
  13. ``====================================================================*)
  14.  
  15. interface
  16.  
  17. const
  18.     MaxPoints        = 500;
  19.     EpsonOk        = 0;
  20.     EpsonOpenFail    = 1;
  21.     EpsonNotOpen    = 2;
  22.     EpsonBounds        = 3;
  23.  
  24. type
  25.     PointType    = record
  26.             X,Y    :Integer
  27.         end;
  28.  
  29. (*---------------------------------------------------------------------.
  30. | NAME: EpsonStatus                                                    |
  31. |                                                                      |
  32. |     This function returns the status of the Epson unit.  A call to   |
  33. | this function will reset the status of the Epson unit.               |
  34. `---------------------------------------------------------------------*)
  35. function EpsonStatus : Integer;
  36.  
  37. (*---------------------------------------------------------------------.
  38. | NAME: OpenPlot                                                       |
  39. |                                                                      |
  40. |     This procedure opens the graphics device.  The FileName          |
  41. | parameter specifies the DOS file or device to send the graphics      |
  42. | output.  The HighDensity parameter selects the high-density plotter  |
  43. | mode if the value of True is passed, otherwise the output is set to  |
  44. | the regular density plotter mode (1:1 pixel size).  This procedure   |
  45. | sets up any memory buffers necessary to store the graphics before    |
  46. | they are output to the printer.                                      |
  47. `---------------------------------------------------------------------*)
  48. procedure OpenPlot (
  49.         HighDensity    : Boolean;
  50.         FileName    : String );
  51.  
  52. (*---------------------------------------------------------------------.
  53. | NAME: ClosePlot                                                      |
  54. |                                                                      |
  55. |     This procedure closes the graphics device.  Any memory buffers   |
  56. | to store the image are deallocated.                                  |
  57. `---------------------------------------------------------------------*)
  58. procedure ClosePlot;
  59.  
  60. (*---------------------------------------------------------------------.
  61. | NAME: DotMaxX                                                        |
  62. |                                                                      |
  63. |     This function returns the maximum horizontal plotting coordinate |
  64. | of the graphics device.  It is assumed that the minimum plotting     |
  65. | coordinate is assumed to be 0.                                       |
  66. `---------------------------------------------------------------------*)
  67. function DotMaxX : Integer;
  68.  
  69. (*---------------------------------------------------------------------.
  70. | NAME: DotMaxY                                                        |
  71. |                                                                      |
  72. |     This function returns the maximum vertical plotting coordinate   |
  73. | of the graphics device.  It is assumed that the minimum plotting     |
  74. | coordinate is assumed to be 0.                                       |
  75. `---------------------------------------------------------------------*)
  76. function DotMaxY : Integer;
  77.  
  78. (*---------------------------------------------------------------------.
  79. | NAME: GetPlotAspectRatio                                             |
  80. |                                                                      |
  81. |     This procedure returns the effective resolution of the graphics  |
  82. | screen from which the aspect ratio (Xasp:Yasp) can be computed.      |
  83. `---------------------------------------------------------------------*)
  84. procedure GetPlotAspectRatio (var Xasp,Yasp : Word);
  85.  
  86. (*---------------------------------------------------------------------.
  87. | NAME: GetPlotX                                                       |
  88. |                                                                      |
  89. |     This function returns the X coordinate of the current plotting   |
  90. | location.                                                            |
  91. `---------------------------------------------------------------------*)
  92. function GetPlotX : Integer;
  93.  
  94. (*--------------------------------------------------------------------*\
  95. | NAME: GetPlotY                                                       |
  96. |                                                                      |
  97. |     This function returns the Y coordinate of the current plotting   |
  98. | location.                                                            |
  99. `---------------------------------------------------------------------*)
  100. function GetPlotY : Integer;
  101.  
  102. (*---------------------------------------------------------------------.
  103. | NAME: MoveTo                                                         |
  104. |                                                                      |
  105. |     This procedure changes coordinate of the current plotting        |
  106. | location.                                                            |
  107. `---------------------------------------------------------------------*)
  108. procedure MoveTo ( x,y : Integer );
  109.  
  110. (*---------------------------------------------------------------------.
  111. | NAME: ClearBitMap                                                    |
  112. |                                                                      |
  113. |     This clears out the memory buffer for storing the graphics.      |
  114. `---------------------------------------------------------------------*)
  115. procedure ClearBitMap;
  116.  
  117. (*---------------------------------------------------------------------.
  118. | NAME: PrintBitMap                                                    |
  119. |                                                                      |
  120. |     This dumps out the contents of the memory buffer for storing the |
  121. | graphics to the printer.                                             |
  122. `---------------------------------------------------------------------*)
  123. procedure PrintBitMap;
  124.  
  125. (*---------------------------------------------------------------------.
  126. | NAME: SetPlotColor                                                   |
  127. |                                                                      |
  128. |     This procedure sets the plotting color for subsequent plotting   |
  129. | output to the graphics device.                                       |
  130. `---------------------------------------------------------------------*)
  131. procedure SetPlotColor ( C : Word );
  132.  
  133. (*---------------------------------------------------------------------.
  134. | NAME: GetPlotColor                                                   |
  135. |                                                                      |
  136. |     This function returns the plotting color for the graphics        |
  137. | device.                                                              |
  138. `---------------------------------------------------------------------*)
  139. function GetPlotColor : Word;
  140.  
  141. (*---------------------------------------------------------------------.
  142. | NAME: PutDot                                                         |
  143. |                                                                      |
  144. |     This procedure puts the pixel value of B at the coordinate (X,Y) |
  145. | on the pixel map.                                                    |
  146. `---------------------------------------------------------------------*)
  147. procedure PutDot ( X,Y : Integer; B : Word );
  148.  
  149. (*---------------------------------------------------------------------.
  150. | NAME: GetDot                                                         |
  151. |                                                                      |
  152. |     This function returns the pixel value at the coordinate (X,Y) on |
  153. | the pixel map.                                                       |
  154. `---------------------------------------------------------------------*)
  155. function GetDot ( X,Y : Integer ) : Integer;
  156.  
  157. (*---------------------------------------------------------------------.
  158. | NAME: Line                                                           |
  159. |                                                                      |
  160. |      This procedure draws a line from (x1,y1) to (x2,y2).            |
  161. `---------------------------------------------------------------------*)
  162. procedure Line ( x1,y1, x2,y2 : Integer );
  163.  
  164. (*---------------------------------------------------------------------.
  165. | NAME: LineTo                                                         |
  166. |                                                                      |
  167. |      This procedure draws a line from the current point to (x,y).    |
  168. `---------------------------------------------------------------------*)
  169. procedure LineTo ( x,y : Integer );
  170.  
  171. (*---------------------------------------------------------------------.
  172. | NAME: PlotRectangle                                                  |
  173. |                                                                      |
  174. |     This procedure draws a rectangle whose opposite corners are at   |
  175. | the coordinates (x1,y1) and (x2,y2).                                 |
  176. `---------------------------------------------------------------------*)
  177. procedure PlotRectangle( x1,y1,x2,y2 : integer );
  178.  
  179. (*---------------------------------------------------------------------.
  180. | NAME: DrawPoly                                                       |
  181. |                                                                      |
  182. |     This procedure draws a polygon defined by the NumPoints points   |
  183. | in PolyPoints.                                                       |
  184. `---------------------------------------------------------------------*)
  185. procedure DrawPoly( NumPoints : Word; var PolyPoints );
  186.  
  187. implementation
  188.  
  189. const
  190.     Xdim    = 8;
  191.     Ydim    = 10;
  192.     MaxHorzDots    = 576;        (* 72 dpi * Xdim = 576 *)
  193.     MaxVertDots    = 720;        (* 72 dpi * Ydim = 720 *)
  194.  
  195.     MaxHorzValue= 575;        (* MaxHorzDots - 1         *)
  196.     MaxVertValue=  89;        (* (MaxVertDots) div 8 - 1 *)
  197.  
  198. type
  199.     BitMap    = array [0..MaxHorzValue,0..MaxVertValue] of byte;
  200.         (* 576 * 720 / 8 = 51840 *)
  201.  
  202. const
  203.     IsDouble    : Boolean    = False;
  204.  
  205. var
  206.     HorzDPI,
  207.     VertDPI    : Integer;
  208.     CurrentX,
  209.     CurrentY    : Integer;
  210.     BitMapFile    : Text;
  211.     StatusCode    : Integer;
  212.     DevIsOpen    : Boolean;
  213.     EvenCols,
  214.     OddCols    : ^BitMap;
  215.  
  216. (*---------------------------------------------------------------------.
  217. | NAME: EpsonStatus                                                    |
  218. `---------------------------------------------------------------------*)
  219. function EpsonStatus : Integer;
  220.     begin
  221.     EpsonStatus := StatusCode;
  222.     StatusCode := EpsonOk
  223.     end;    (* ErrorStatus *)
  224.  
  225. (*---------------------------------------------------------------------.
  226. | NAME: OpenPlot                                                       |
  227. `---------------------------------------------------------------------*)
  228. procedure OpenPlot (
  229.         HighDensity    : Boolean;
  230.         FileName    : String );
  231.     begin
  232.     if DevIsOpen then
  233.         Close(BitMapFile);
  234.     Assign(BitMapFile,FileName);
  235.     {$I-}
  236.     ReWrite(BitMapFile);
  237.     {$I+}
  238.     if IOResult <> 0 then
  239.         StatusCode := EpsonOpenFail
  240.     else begin
  241.         IsDouble := HighDensity;
  242.         if not DevIsOpen then begin
  243.         New(EvenCols);
  244.         if HighDensity then
  245.             New(OddCols);
  246.           end;
  247.         VertDPI := 72;
  248.         if HighDensity then
  249.         HorzDPI := 144
  250.         else
  251.         HorzDPI := 72;
  252.         DevIsOpen := True;
  253.         ClearBitMap
  254.       end
  255.     end;    (* OpenPlot *)
  256.  
  257. (*---------------------------------------------------------------------.
  258. | NAME: ClosePlot                                                      |
  259. `---------------------------------------------------------------------*)
  260. procedure ClosePlot;
  261.     begin
  262.     if not DevIsOpen then begin
  263.         StatusCode := EpsonNotOpen;
  264.         Exit
  265.       end;
  266.     Close(BitMapFile);
  267.     Dispose(EvenCols);
  268.     if IsDouble then
  269.         Dispose(OddCols);
  270.     DevIsOpen := False;
  271.     StatusCode := EpsonOk
  272.     end;    (* ClosePlot *)
  273.  
  274. (*---------------------------------------------------------------------.
  275. | NAME: DotMaxX                                                        |
  276. `---------------------------------------------------------------------*)
  277. function DotMaxX : Integer;
  278.     begin
  279.     if not DevIsOpen then
  280.         StatusCode := EpsonNotOpen;
  281.     if IsDouble then
  282.         DotMaxX := (MaxHorzDots * 2) - 1
  283.     else
  284.         DotMaxX := MaxHorzDots - 1;
  285.     StatusCode := EpsonOk
  286.     end;    (* DotMaxX *)
  287.  
  288. (*---------------------------------------------------------------------.
  289. | NAME: DotMaxY                                                        |
  290. `---------------------------------------------------------------------*)
  291. function DotMaxY : Integer;
  292.     begin
  293.     if not DevIsOpen then
  294.         StatusCode := EpsonNotOpen;
  295.     DotMaxY := MaxVertDots - 1;
  296.     StatusCode := EpsonOk
  297.     end;    (* DotMaxY *)
  298.  
  299. (*---------------------------------------------------------------------.
  300. | NAME: GetPlotX                                                       |
  301. `---------------------------------------------------------------------*)
  302. function GetPlotX : Integer;
  303.     begin
  304.     GetPlotX := CurrentX
  305.     end;    (* GetPlotX *)
  306.  
  307. (*---------------------------------------------------------------------.
  308. | NAME: GetPlotY                                                       |
  309. `---------------------------------------------------------------------*)
  310. function GetPlotY : Integer;
  311.     begin
  312.     GetPlotY := CurrentY
  313.     end;    (* GetPlotX *)
  314.  
  315. (*---------------------------------------------------------------------.
  316. | NAME: MoveTo                                                         |
  317. `---------------------------------------------------------------------*)
  318. procedure MoveTo ( x,y : Integer );
  319.     begin
  320.     CurrentX := X;
  321.     CurrentY := Y
  322.     end;    (* MoveTo *)
  323.  
  324. (*---------------------------------------------------------------------.
  325. | NAME: GetPlotAspectRatio                                             |
  326. `---------------------------------------------------------------------*)
  327. procedure GetPlotAspectRatio (var Xasp,Yasp : Word);
  328.     begin
  329.     if not DevIsOpen then begin
  330.         StatusCode := EpsonNotOpen;
  331.         Exit
  332.       end;
  333.     Xasp := 7200 div HorzDPI;
  334.     Yasp := 7200 div VertDPI
  335.     end;    (* GetPlotAspectRatio *)
  336.  
  337. (*---------------------------------------------------------------------.
  338. | NAME: ClearBitMap                                                    |
  339. `---------------------------------------------------------------------*)
  340. procedure ClearBitMap;
  341.     begin
  342.     if not DevIsOpen then begin
  343.         StatusCode := EpsonNotOpen;
  344.         Exit
  345.       end;
  346.     CurrentX := 0;
  347.     CurrentY := 0;
  348.     FillChar(EvenCols^,sizeof(EvenCols^),0);
  349.     if IsDouble then
  350.         FillChar(OddCols^,sizeof(OddCols^),0);
  351.     StatusCode := EpsonOk
  352.     end;    (* ClearBitMap *)
  353.  
  354. (*---------------------------------------------------------------------.
  355. | NAME: PrintBitMap                                                    |
  356. `---------------------------------------------------------------------*)
  357. procedure PrintBitMap;
  358.     var
  359.     i,j    : Integer;
  360.     begin
  361.     if not DevIsOpen then begin
  362.         StatusCode := EpsonNotOpen;
  363.         Exit
  364.       end;
  365.     Write(BitMapFile,#27'A'#8);    (* set to 8/72" spacing *)
  366.     for i := (MaxVertDots div 8)-1 downto 0 do begin
  367.         if IsDouble then begin
  368.         Write(BitMapFile,#27'*'#7,
  369.             Chr(lo(MaxHorzDots*2)),Chr(hi(MaxHorzDots*2)) );
  370.         for j := 0 to MaxHorzDots-1 do
  371.             Write(BitMapFile,
  372.             Chr(EvenCols^[j,i]),Chr(OddCols^[j,i]))
  373.           end
  374.         else begin
  375.         Write(BitMapFile,#27'*'#5,
  376.             Chr(lo(MaxHorzDots)),Chr(hi(MaxHorzDots)));
  377.         for j := 0 to MaxHorzDots-1 do
  378.             Write(BitMapFile,Chr(EvenCols^[j,i]))
  379.           end;
  380.         WriteLn(BitMapFile)
  381.       end;
  382.     Write(BitMapFile,#12#27'@');    (* Form feed & reset printer *)
  383.     StatusCode := EpsonOk
  384.     end;    (* PrintBitMap *)
  385.  
  386. var
  387.     PlotColor    : Word;
  388.  
  389. (*---------------------------------------------------------------------.
  390. | NAME: SetPlotColor                                                   |
  391. `---------------------------------------------------------------------*)
  392. procedure SetPlotColor ( C : Word );
  393.     begin
  394.     PlotColor := C
  395.     end;    (* SetPlotColor *)
  396.  
  397. (*---------------------------------------------------------------------.
  398. | NAME: GetPlotColor                                                   |
  399. `---------------------------------------------------------------------*)
  400. function GetPlotColor : Word;
  401.     begin
  402.     GetPlotColor := PlotColor
  403.     end;    (* GetPlotColor *)
  404.  
  405. (*---------------------------------------------------------------------.
  406. | NAME: PutDot                                                         |
  407. `---------------------------------------------------------------------*)
  408. procedure PutDot ( X,Y : Integer; B : Word );
  409.     var
  410.     i,j,k    : Integer;
  411.     begin
  412.     if not DevIsOpen then begin
  413.         StatusCode := EpsonNotOpen;
  414.         Exit
  415.       end;
  416.     CurrentX := X;
  417.     CurrentY := Y;
  418.     if not IsDouble then
  419.         X := X * 2;
  420.     if (X < 0) or (X >= MaxHorzDots*2)
  421.       or (Y < 0) or (Y >= MaxVertDots) then
  422.         Exit;
  423.     i := X div 2;
  424.     j := Y div 8;
  425.     if B<>0 then begin
  426.         k := 1 shl (Y mod 8);
  427.         if Odd(X) then
  428.         OddCols^[i,j] := lo(OddCols^[i,j] or k)
  429.         else
  430.         EvenCols^[i,j] := lo(EvenCols^[i,j] or k)
  431.       end
  432.     else begin
  433.         k := not (1 shl (Y mod 8));
  434.         if Odd(X) then
  435.         OddCols^[i,j] := lo(OddCols^[i,j] and k)
  436.         else
  437.         EvenCols^[i,j] := lo(EvenCols^[i,j] and k)
  438.       end;
  439.     StatusCode := EpsonOk
  440.     end;    (* PutDot *)
  441.  
  442. (*---------------------------------------------------------------------.
  443. | NAME: GetDot                                                         |
  444. `---------------------------------------------------------------------*)
  445. function GetDot ( X,Y : Integer ) : Integer;
  446.     var
  447.     i,j,k    : Integer;
  448.     begin
  449.     if not DevIsOpen then begin
  450.         StatusCode := EpsonNotOpen;
  451.         Exit
  452.       end;
  453.     if not IsDouble then
  454.         X := X * 2;
  455.     if (X < 0) or (X >= MaxHorzDots*2)
  456.       or (Y < 0) or (Y >= MaxVertDots) then
  457.         GetDot := 0
  458.     else begin
  459.         i := X div 2;
  460.         j := Y div 8;
  461.         k := 1 shl (Y mod 8);
  462.         if Odd(X) then
  463.         if (OddCols^[i,j] and k) <> 0
  464.         then GetDot := 1
  465.         else GetDot := 0
  466.         else
  467.         if (EvenCols^[i,j] and k) <> 0
  468.         then GetDot := 1
  469.         else GetDot := 0;
  470.       end;
  471.     StatusCode := EpsonOk
  472.     end;    (* GetDot *)
  473.  
  474. (*---------------------------------------------------------------------.
  475. | NAME: HorzLine                                                       |
  476. `---------------------------------------------------------------------*)
  477. procedure HorzLine ( x1,x2,y : Integer );
  478.     var
  479.     i    : Integer;
  480.     begin
  481.     if x1>x2 then
  482.         for i := x2 to x1 do
  483.         PutDot(i,y,PlotColor)
  484.     else
  485.         for i := x1 to x2 do
  486.         PutDot(i,y,PlotColor)
  487.     end;    (* HorzLine *)
  488.  
  489. (*---------------------------------------------------------------------.
  490. | NAME: VertLine                                                       |
  491. `---------------------------------------------------------------------*)
  492. procedure VertLine ( x,y1,y2 : Integer );
  493.     var
  494.     i    : Integer;
  495.     begin
  496.     if y1>y2 then
  497.         for i := y2 to y1 do
  498.         PutDot(x,i,PlotColor)
  499.     else
  500.         for i := y1 to y2 do
  501.         PutDot(x,i,PlotColor)
  502.     end;    (* VertLine *)
  503.  
  504. (*---------------------------------------------------------------------.
  505. | NAME: Line_XY                                                        |
  506. `---------------------------------------------------------------------*)
  507. procedure Line_XY ( x1,y1, x2,y2 : Integer );
  508.     var
  509.     d,dx,dy,
  510.     Aincr,Bincr,Yincr,
  511.     x,y            : Integer;
  512.     begin
  513.     if x1>x2 then begin
  514.         x := x1;    x1 := x2;    x2 := x;
  515.         x := y1;    y1 := y2;    y2 := x
  516.       end;
  517.     if y2>y1 then
  518.         Yincr := 1
  519.     else
  520.         Yincr := -1;
  521.     dx := x2-x1;
  522.     dy := abs(y2-y1);
  523.     d := 2*dy-dx;
  524.  
  525.     Aincr := 2 * (dy-dx);
  526.     Bincr := 2 * dy;
  527.  
  528.     x := x1;
  529.     y := y1;
  530.  
  531.     PutDot(x,y,PlotColor);
  532.  
  533.     for x:= x1+1 to x2 do begin
  534.         if d < 0 then
  535.         Inc(d,Bincr)
  536.         else begin
  537.         Inc(y,Yincr);
  538.         Inc(d,Aincr)
  539.           end;
  540.         PutDot(x,y,PlotColor)
  541.       end
  542.     end;    (* Line_XY *)
  543.  
  544. (*---------------------------------------------------------------------.
  545. | NAME: Line_YX                                                        |
  546. `---------------------------------------------------------------------*)
  547. procedure Line_YX ( x1,y1, x2,y2 : Integer );
  548.     var
  549.     d,dx,dy,
  550.     Aincr,Bincr,Xincr,
  551.     x,y            : Integer;
  552.     begin
  553.     if y1>y2 then begin
  554.         x := x1;    x1 := x2;    x2 := x;
  555.         x := y1;    y1 := y2;    y2 := x
  556.       end;
  557.     if x2>x1 then
  558.         Xincr := 1
  559.     else
  560.         Xincr := -1;
  561.     dy := y2-y1;
  562.     dx := abs(x2-x1);
  563.     d := 2*dx-dy;
  564.  
  565.     Aincr := 2 * (dx-dy);
  566.     Bincr := 2 * dx;
  567.  
  568.     x := x1;
  569.     y := y1;
  570.  
  571.     PutDot(x,y,PlotColor);
  572.  
  573.     for y:= y1+1 to y2 do begin
  574.         if d < 0 then
  575.         Inc(d,Bincr)
  576.         else begin
  577.         Inc(x,Xincr);
  578.         Inc(d,Aincr)
  579.           end;
  580.         PutDot(x,y,PlotColor)
  581.       end
  582.     end;    (* Line_YX *)
  583.  
  584. (*---------------------------------------------------------------------.
  585. | NAME: Line                                                           |
  586. `---------------------------------------------------------------------*)
  587. procedure Line ( x1,y1, x2,y2 : Integer );
  588.     begin
  589.     if x1=x2 then VertLine(x1,y1,y2)
  590.     else if y1=y2 then HorzLine(x1,x2,y1)
  591.     else if Abs(x1-x2) >= Abs(y1-y2) then Line_XY(x1,y1,x2,y2)
  592.     else Line_YX(x1,y1,x2,y2);
  593.     CurrentX := x2;
  594.     CurrentY := y2
  595.     end;
  596.  
  597. (*---------------------------------------------------------------------.
  598. | NAME: LineTo                                                         |
  599. `---------------------------------------------------------------------*)
  600. procedure LineTo ( x,y : Integer );
  601.     begin
  602.     Line(CurrentX,CurrentY, X,Y)
  603.     end;
  604.  
  605. (*---------------------------------------------------------------------.
  606. | NAME: PlotRectangle                                                  |
  607. `---------------------------------------------------------------------*)
  608. procedure PlotRectangle( x1,y1,x2,y2 : integer );
  609.     var
  610.     i    : Integer;
  611.     begin
  612.     HorzLine(x1,x2,y1);
  613.     HorzLine(x1,x2,y2);
  614.     VertLine(x1,y1,y2);
  615.     VertLine(x2,y1,y2)
  616.     end;    (* PlotRectangle *)
  617.  
  618. (*---------------------------------------------------------------------.
  619. | NAME: DrawPoly                                                       |
  620. `---------------------------------------------------------------------*)
  621. procedure DrawPoly( NumPoints : Word; var PolyPoints );
  622.     var
  623.     i    : integer;
  624.     PtTbl    : array [0..MaxPoints] of PointType absolute PolyPoints;
  625.     begin
  626.     with PtTbl[0] do
  627.         MoveTo(x,y);
  628.     for i := 1 to NumPoints-1 do
  629.         with PtTbl[i] do
  630.         LineTo(x,y);
  631.     with PtTbl[0] do
  632.         LineTo(x,y);
  633.     end;    (* DrawPoly *)
  634.  
  635. {$F+}
  636. var
  637.     OldExitProc    : Pointer;
  638.  
  639. (*---------------------------------------------------------------------.
  640. | NAME: CleanUp                                                        |
  641. `---------------------------------------------------------------------*)
  642. procedure CleanUp;
  643.     begin
  644.     ExitProc := OldExitProc;
  645.     if DevIsOpen then
  646.         ClosePlot
  647.     end;    (* CleanUp *)
  648. {$F-}
  649.  
  650. begin
  651.     IsDouble := False;
  652.     DevIsOpen := False;
  653.     OldExitProc := ExitProc;
  654.     ExitProc := @CleanUp
  655. end.
  656.